package com.xiaoyi.config;

import com.xiaoyi.enums.AlgorithmEnum;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Objects;

/**
 * @author xiaoyi
 * @version 1.0.0
 * @date 2023/07/30 15:28:00
 */
@ConfigurationProperties(prefix = "mybatis.encryption")
public class EncryptionConfig {
    private boolean enable;
    private boolean enableEncrypt;
    private boolean enableDecrypt;
    private String password;
    private String algorithmType;
    private String publicKey;
    private String privateKey;



    public boolean getEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean getEnableEncrypt() {
        return enableEncrypt;
    }

    public void setEnableEncrypt(boolean enableEncrypt) {
        this.enableEncrypt = enableEncrypt;
    }

    public boolean getEnableDecrypt() {
        return enableDecrypt;
    }

    public void setEnableDecrypt(boolean enableDecrypt) {
        this.enableDecrypt = enableDecrypt;
    }

    public String getAlgorithmType() {
        return algorithmType;
    }

    public void setAlgorithmType(String algorithmType) {
        this.algorithmType = algorithmType;
    }

    public AlgorithmEnum getAlgorithm() {

        if (Objects.isNull(algorithmType) || "".equals(algorithmType)) {
            return null;
        }
        AlgorithmEnum algorithmEnum = AlgorithmEnum.getAlgorithmEnumBykey(algorithmType);
        if (Objects.isNull(algorithmEnum)) {
            return algorithmEnum;
        }
        return algorithmEnum;
    }

    public String getPublicKey() {
        return publicKey;
    }

    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }
}
